<%@ page pageEncoding="UTF-8"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.example.entity.Article" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="test/html;utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WEB-INF/jsp/listArticles.jsp</title>
    <%@ include file="../comm/header.jsp" %>
    <script src="../../static/js/test.js"></script>
</head>
<body>
<div class="container">
    <h3>文章列表页:</h3>
    <a class="btn btn-primary" href="/articleadd" role="button">添加文章</a>
    <table>
        <tr>
            <th>序号</th>
            <th>编号</th>
            <th>标题</th>
            <th>作者</th>
        </tr>
        
        <%
        // 获得article数组
        ArrayList articles = (ArrayList)request.getSession().getAttribute("articles");
        // 解包数组
        for(int i=0;i<articles.size();i++){
            Article article=(Article)articles.get(i);
        %>
        <tr>
        <td><%=i%></td>
        <td><%=article.getId()%></td>
        <td><a href="/articleDetail?index=<%=i%>"><%=article.getTitle()%></a></td>
        <td><%=article.getAuthor()%></td>
        </tr>
        <%}%>
        
    </table>
</div>
</body>
</html>